package lamma.test.helper;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author maxcellent
 *
 */
public class FutureHelper {
	
	/**
	 * @param <T>
	 * @param millis
	 * @param result
	 * @return
	 */
	public static <T> Future<T> mockFuture(final long millis, final T result) {
		ExecutorService executor = Executors.newFixedThreadPool(1);
		return executor.submit(new Callable<T>() {
			@Override
			public T call() throws Exception {
				Thread.sleep(millis);
				return result;
			}
		});
	}
	
}
